home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / FLI106C.ZIP;1 / BLTEXT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-12  |  4.2 KB  |  296 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.06c
  4. // Copyright (C) 1990, 1991, 1992
  5. // Software Dimensions
  6. //
  7. // BlazeClass
  8. //
  9.  
  10. #ifndef __BCPLUSPLUS__
  11. #pragma inline
  12. #endif
  13.  
  14. #include "fli.h"
  15.  
  16. #ifdef __BCPLUSPLUS__
  17. #pragma hdrstop
  18. #endif
  19.  
  20. #include <dos.h>
  21.  
  22. #define I asm
  23.  
  24. extern int SingleCharacter;
  25.  
  26. #if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
  27. #define ISFAR
  28. #endif
  29.  
  30. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  31. //
  32. // << operator
  33. //
  34. // Output text
  35. //
  36. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  37.  
  38. BlazeClass& BlazeClass::operator<< (char *String)
  39. {
  40.   if (!String)
  41.     return *this;
  42.  
  43.   int WinHigh =     BlazeClass::WinHigh;
  44.   int WinWide =     BlazeClass::WinWide;
  45.   int WinX =        BlazeClass::WinX;
  46.   int WinY =        BlazeClass::WinY;
  47.   int ScreenWidth = BlazeClass::QuickWidth;
  48.   int Clip =        BlazeClass::Clip;
  49.   int X =           BlazeClass::X;
  50.   int Y =           BlazeClass::Y;
  51.   int Scrolling =   BlazeClass::Scrolling;
  52.   int Color =       BlazeClass::Color;
  53.   int SinChar =     SingleCharacter;
  54.  
  55.   if (Center || FlushRight)
  56.   {
  57.     #ifndef ISFAR
  58.       I mov ax,ds
  59.       I mov es,ax
  60.       I mov di,String
  61.       I xor ax,ax
  62.     #else
  63.       I les di,String
  64.       I xor ax,ax
  65.       I cmp ax,(word ptr (String) [2])
  66.       I jne Start
  67.       I cmp ax,di
  68.       I je Out
  69.     #endif
  70.  
  71.     Start:
  72.  
  73.     I cld
  74.     I mov cx, -1
  75.     I repne scasb
  76.     I xchg ax,cx
  77.     I not ax
  78.     I dec ax
  79.     I mov di,ax
  80.  
  81.     if (Center)
  82.     {
  83.       if (_DI>WinWide)
  84.         _DX=0;
  85.       else
  86.         _DX=(WinWide-_DI)>>1;
  87.       X=_DX;
  88.       Center=0;
  89.       goto Begin;
  90.     }
  91.     else
  92.     {
  93.       if (_DI>WinWide)
  94.         _DX=0;
  95.       else
  96.         _DX=WinWide-_DI;
  97.       X=_DX;
  98.       FlushRight=0;
  99.       goto Begin;
  100.     }
  101.  
  102.     Out:
  103.  
  104.     return *this;
  105.   }
  106.  
  107. Begin:
  108.  
  109.   #ifdef ISFAR
  110.     I push ds
  111.     I lds si,String
  112.   #else
  113.     I mov si,String
  114.   #endif
  115.  
  116.   void far *OUTPUT=BlazeClass::OUTPUT;
  117.  
  118. ComputeVideoCoordinates:
  119.  
  120.   I les di,OUTPUT
  121.  
  122.   _DI += ((WinY+Y)*ScreenWidth)+((WinX+X)*2);
  123.  
  124.   I mov ah,byte ptr Color
  125.   I cld
  126.  
  127. StringLoop:
  128.  
  129.   I lodsb
  130.   I or al,al
  131.   I jne TestLineFeed
  132.  
  133.   #ifdef ISFAR
  134.     I pop ds
  135.   #endif
  136.  
  137.   BlazeClass::Y=Y;
  138.   BlazeClass::X=X;
  139.  
  140.   return *this;
  141.  
  142. TestLineFeed:
  143.  
  144.   if (!SinChar)
  145.   {
  146.  
  147.       I cmp al,10
  148.       I jne TestCarraigeReturn
  149.       I jmp LineFeed
  150.  
  151.     TestCarraigeReturn:
  152.  
  153.       I cmp al,13
  154.       I jne DisplayCharacter
  155.  
  156.       X=0;
  157.  
  158.       I jmp ComputeVideoCoordinates
  159.  
  160.   }
  161.  
  162. DisplayCharacter:
  163.  
  164.   if (!Clip)
  165.   {
  166.     I stosw
  167.  
  168.     X++;
  169.  
  170.     I mov dx,word ptr WinWide
  171.     I cmp word ptr X,dx
  172.     I jl StringLoop
  173.  
  174.     goto Assess;
  175.   }
  176.   else
  177.   {
  178.     I mov dx,word ptr WinWide
  179.     I cmp word ptr X,dx
  180.     I jl Next
  181.     I jmp VirReality
  182.  
  183. Next:
  184.  
  185.     I mov dx,word ptr WinHigh
  186.     I cmp word ptr Y,dx
  187.     I jl Output
  188.  
  189. VirReality:
  190.  
  191.     // Virtual reality
  192.  
  193.     I inc di
  194.     I inc di
  195.  
  196.     X++;
  197.  
  198.     goto StringLoop;
  199.  
  200.     // Visual reality
  201.  
  202. Output:
  203.  
  204.     I stosw
  205.  
  206.     X++;
  207.  
  208.     goto StringLoop;
  209.   }
  210.  
  211. Assess:
  212.  
  213.   X=0;
  214.  
  215. LineFeed:
  216.  
  217.   if (!Clip)
  218.   {
  219.     I mov cx,WinHigh
  220.     I dec cx
  221.     I cmp cx,Y
  222.     I je BumpUpLines
  223.   }
  224.  
  225.   Y++;
  226.  
  227.   I jmp ComputeVideoCoordinates
  228.  
  229. BumpUpLines:
  230.  
  231.   if (Scrolling)
  232.     goto ScrollWindow;
  233.  
  234.   X=0;
  235.  
  236.   I jmp ComputeVideoCoordinates
  237.  
  238. ScrollWindow:
  239.  
  240.   _DI = FP_OFF(OUTPUT);
  241.  
  242.   if (WinX || WinY)
  243.     _DI += ((WinY*ScreenWidth)+(WinX*2));
  244.  
  245.   I push si
  246.   I mov si,di
  247.   I mov cx,WinWide
  248.   I mov dx,WinHigh
  249.   I dec dx
  250.   I mov bx,cx
  251.   I mov ax,es
  252.   I push ds
  253.   I mov ds,ax
  254.   I mov si,di
  255.   I add si,ScreenWidth
  256.   I cld
  257.  
  258. looped:
  259.  
  260.   I push di
  261.   I push si
  262.  
  263.   I mov cx,bx
  264.   I rep movsw
  265.  
  266.   I pop si
  267.   I pop di
  268.   I add si,ScreenWidth
  269.   I add di,ScreenWidth
  270.   I dec dx
  271.   I or dx,dx
  272.   I jne looped
  273.  
  274.   I pop ds
  275.   I pop si
  276.  
  277.   _DI = FP_OFF(OUTPUT);
  278.  
  279.   if (!WinX && !WinY)
  280.     _DI += ((WinHigh-1)*ScreenWidth);
  281.   else
  282.     _DI += (((WinY+WinHigh-1)*ScreenWidth)+(WinX*2));
  283.  
  284.   I mov cx,WinWide
  285.  
  286.   I mov al,32
  287.   I mov ah,byte ptr Color
  288.   I rep stosw
  289.  
  290.   X=0;
  291.   I jmp ComputeVideoCoordinates
  292.  
  293.   return *this;
  294. }
  295.  
  296.